package com.lyy.polymorphic.object_;


/**
 * @Author: GZQ
 * @date: 2024/11/21 23:02
 * @description: 练习
 */

public class EqualsExercise02 {

    public static void main(String[] args) {
        Person_ p1 = new Person_();
        p1.name = "jack";

        Person_ p2 = new Person_();
        p2.name = "jack";

        System.out.println(p1 == p2); // false
        System.out.println(p1.name.equals(p2.name)); // true
        System.out.println(p1.equals(p2)); // false

        String s1 = new String("hello");

        String s2 = new String("hello");

        System.out.println(s1 == s2); // false
        System.out.println(s1.equals(s2)); // true
    }
}

class Person_ {
    public String name;
}